######################################################################
# Time-stamp: <05/08/09 17:03:28 ostolop>
#
# Routines to validate Data Upload queries
######################################################################
package EP::EPC::Interface::Validator::Data_Upload;
use strict;

use EP::Common;
use EP::Common::Error qw ( :try );

use Carp;

sub new {
  my $proto = shift;
  my $class = ref($proto) || $proto;
  my $self  = {};
  bless $self, $class;
  return $self;
}

sub validate {
  my $self = shift;
  my ($component, $source) = @_;

  my $err_code = "";

  # if uploading from URL
  if ( $component->findvalue('section[@id=0]/@active_subsection_id') == 2 ) {
    try {
      checkValidURL ( $component, $source );
    } catch EP::Common::Error with {
      my $e = shift;
      carp $e;
      $err_code = $e->stringify;
    };
  }

  return $err_code;
}

sub checkValidURL {
  my ($component, $source) = @_;

  my $username = $component->findvalue ('section[@id=0]/subsection[@id=2]/submit[@name=\'src_url___c_1_s_0_su_2\']/value');
# TODO: check URL, clean, etc.

  return "";
}


1;
